package com.MartynovichIgor.KnowledgeTest.tools.admintools;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ResourceBundle;

/**
 * Created by:
 * User: Igor Martynovich and Guzenko Igor
 * Date: 03.11.13
 */
public class AdminAction {
    private Admin admin;
    private ResourceBundle languageChooser;

    public AdminAction(Admin newAdmin, ResourceBundle languageChooser) {
        this.admin = newAdmin;
        this.languageChooser = languageChooser;
    }

    public void performActions() throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        System.out.println(languageChooser.getString("adminHelp"));
        String adminInput = reader.readLine();
        while (!adminInput.equals("exit")) {
            if(adminInput.equals("info")) {
                admin.viewAllUsers();
            }
            if(adminInput.equals("delete")) {
                System.out.println(languageChooser.getString("deadUser"));
                admin.deleteUser(reader.readLine());
            }
            if(adminInput.equals("u_stat")){
                System.out.println(languageChooser.getString("seeUserStat"));
                admin.viewStatisticsByLogin(reader.readLine());
            }
            if(adminInput.equals("stats")){
                admin.viewAllStatistics();
            }
            adminInput = reader.readLine().toLowerCase();
        }
    }





}
